package org.theSeed.webFlux.handler;

import org.springframework.web.reactive.socket.WebSocketHandler;
import org.springframework.web.reactive.socket.WebSocketSession;
import reactor.core.publisher.Mono;

/**
 * 案例
 */
public class WebSocketHandlerImpl implements WebSocketHandler {
    @Override
    public Mono<Void> handle(WebSocketSession session) {
        return session.send(session.receive()
                .map(msg->session.textMessage("收到!"+msg.getPayloadAsText())));
    }
}
